<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta content="IE=8" http-equiv="X-UA-Compatible" />
        <title>添加角色</title>
        {$QPath}
        <link rel="stylesheet" type="text/css" href="__TMPL__../Admin/Public/base.css" />
        <style type="text/css">
            label.item{margin-left:8px;}
            .popelist{
                float:left;
                margin:3px 6px;
                background-color:#FAFAF6;
                -moz-border-radius:4px;
                border:1px solid #aaaaaa;
                padding:8px 16px;
                width:100p\x;
            }
            .popelist li{
                line-height:20px;
                font-size:12px;
            }
            .popelist .ultitle{
                height:16px;
                line-height:16px;
                font-weight:bold;
                font-size:13px;
                padding-bottom:8px;
            }
            .popelist label{
                color:#545454;
                margin:0;
            }
        </style>
        <script type="text/javascript">
            var _validate=[
                ['name',[
                        {rule:'required',msg:'角色名称必须填写'}
                    ]
                ]
            ];
        </script>
        <script type="text/javascript" src="__TMPL__../Admin/Public/mootools.js"></script>
        <script type="text/javascript" src="__TMPL__../Admin/Public/base.js"></script>
    </head>
    <body>
        <div id="container">
            <table class="tabmenu" cellspacing="0">
                <tbody>
                    <tr>
                        <td class="wedge">&nbsp;</td>
                        <td class="wmenu"><a href="__APP__/pUser/index"><span>用户列表</span></a></td>
                        <td class="wmenu"><a href="__APP__/pUser/add"><span>添加用户</span></a></td>
                        <td class="wmenu"><a href="__URL__/index"><span>角色列表</span></a></td>
                        <td class="wmenu"><a href="__URL__/add"><span>添加角色</span></a></td>
                        <td class="wmenu here">更改角色</td>
                        <td>&nbsp;</td>
                    </tr>
                </tbody>
            </table>
            <div class="main">
                <p class="editpage">
                    更改角色<b>{$rs['name']}</b>的信息
                </p>
                <ul class="fnc">
                    <li>
                        <button type="button" class="btn" onclick="doUpdate()">更新</button>
                    </li>
                </ul>
                <form id="ipsForm" method="post" action="__URL__">
                    <input type="hidden" name="a"/>
                    <input type="hidden" name="id" value="{$rs['id']}"/>
                    <table class="ips">
                        <tbody>
                            <tr>
                                <th class="essential"><label for="pk1">角色名称</label></th>
                                <td>
                                    <input id="pk1" type="text" name="name" maxlength="32" size="40" value="{$rs['name']}"/>
                                    <p class="hint">长度不能超过32个字符</p>
                                </td>
                            </tr>
                            <tr>
                                <th><label>角色状态</label></th>
                                <td>
                                    <p><input id="statusOn" type="radio" name="status" value="1" /><label for="statusOn" class="item">启用</label></p>
                                    <p><input id="statusOff" type="radio" name="status" value="0" /><label for="statusOff" class="item">禁用</label></p>
                                    <script type="text/javascript">
                                        $("status"+(("{$rs['status']}"=="1")?"On":"Off")).setProperty("checked",true);
                                    </script>
                                </td>
                            </tr>
                            <tr>
                                <th><label>权限</label></th>
                                <td>
                                    <div id="popelist">
                                        <iterate name="popelist" id="bundle">
                                            <ul class="popelist">
                                                <li class="ultitle">{$bundle.name}</li>
                                                <iterate name="bundle['sub']" id="pope">
                                                <li>
                                                    <input type="checkbox" name="popedom[]" id="pope{$pope.id}" value="{$pope.id}"/>
                                                    <label for="pope{$pope.id}">{$pope.name}</label>
                                                </li>
                                                </iterate>
                                            </ul>
                                        </iterate>
                                    </div>
                                    <script type="text/javascript">
                                        var popes=[{$popes}];
                                        for(var i=0,len=popes.length;i<len;i++){
                                            var pope=$('pope'+popes[i]);
                                            pope.setProperty("checked",true);
                                            pope.getNext('label').setStyle('background-color','#e8f4be');
                                        }
                                    </script>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
                <ul class="fnc">
                    <li>
                        <button type="button" class="btn" onclick="doUpdate()">更新</button>
                    </li>
                </ul>
            </div>
        </div>
        <script type="text/javascript">
            function doUpdate(){
                doAction('update',{
                    submitType:'ajax',
                    ajaxOptions:{
                        runningMsg:'正在更新角色信息，请等候',
                        successMsg:'成功更新了角色<b>{$rs['name']}</b>的信息'
                    }
                });
            }
            $(window).addEvent('domready',function(){
                $$('#popelist input').each(function(ips){
                    ips.addEvent('change',function(){
                        var label=this.getNext('label');
                        if(this.getProperty('checked')) label.setStyle('background-color','#e8f4be');
                        else label.setStyle('background-color','transparent');
                    });
                });
            });
        </script>
    </body>
</html>
